package com.Eastiy.EXO.View;

import android.content.Context;
import android.view.MotionEvent;
import android.view.View;
import android.widget.PopupWindow;

public class NewMoveCB {

    /* renamed from: QH */
    public static boolean f37QH = false;
    /* access modifiers changed from: private */
    public static boolean canmovew = false;
    public static Context context;

    /* renamed from: X */
    int f38X;

    /* renamed from: Y */
    int f39Y;

    /* renamed from: H */
    public static int m34H() {
        return context.getResources().getDisplayMetrics().heightPixels;
    }

    /* renamed from: W */
    public static int m35W() {
        return context.getResources().getDisplayMetrics().widthPixels;
    }

    public PopupWindow NewMoveCB(Context context2, Object obj, boolean z, Object[] objArr, int i, int i2) {
        context = context2;
        this.f38X = i;
        this.f39Y = i2;
        NewView newView = new NewView(context2, new Integer((int) (((double) m34H()) * 0.1d)), new Integer((int) (((double) m34H()) * 0.1d)), "CC", new Integer(1), 2, (Object) null, (Object) null, (View.OnClickListener) null);
        NewView newView2 = new NewView(context2, new Integer((int) (((double) m34H()) * 0.1d)), new Integer((int) (((double) m34H()) * 0.1d)), "CC", new Integer(1), 1, "#000000", new Integer(15), (View.OnClickListener) null);
        if (objArr[1] == new Boolean(true)) {
            f37QH = true;
            newView2.setBackgroundDrawable(ASUI.roundBG(new String[]{"#DAFFCE", "#BBFFEA", "LR"}, new Integer(15), (String) null, (Object) null));
        } else {
            f37QH = false;
            newView2.setBackgroundDrawable(ASUI.roundBG("#000000", new Integer(15), (String) null, (Object) null));
        }
        NewText newText = new NewText(context2, obj, "CC", 15, "#00FF00");
        newView.addView(newView2);
        newView2.addView(newText);
        NewCDV newCDV = new NewCDV(newView, new Integer((int) (((double) m34H()) * 0.1d)), new Integer((int) (((double) m34H()) * 0.1d)), false, true, true, "CC", (Object) null, this.f38X, this.f39Y);
        newView2.setOnLongClickListener(new View.OnLongClickListener(this) {
            private final NewMoveCB this$0;

            {
                this.this$0 = r1;
            }

            static NewMoveCB access$0(AnonymousClass100000000 r1) {
                return r1.this$0;
            }

            @Override
            public boolean onLongClick(View view) {
                NewMoveCB.canmovew = true;
                return false;
            }
        });
        newView2.setOnTouchListener(new View.OnTouchListener(this, objArr, newView2, newCDV) {
            private float lastX;
            private float lastY;
            private float nowX;
            private float nowY;
            private final NewMoveCB this$0;
            private float tranX;
            private float tranY;
            private final NewCDV val$NewMoveCBcdv;
            private final NewView val$_nmcbll2;
            private final Object[] val$runs;

            {
                this.this$0 = r1;
                this.val$runs = r2;
                this.val$_nmcbll2 = r3;
                this.val$NewMoveCBcdv = r4;
            }

            static NewMoveCB access$0(AnonymousClass100000001 r1) {
                return r1.this$0;
            }

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                int action = motionEvent.getAction();
                if (action == 0) {
                    this.lastX = motionEvent.getRawX();
                    this.lastY = motionEvent.getRawY();
                } else if (action == 1) {
                    if (!NewMoveCB.canmovew) {
                        ((View.OnClickListener) this.val$runs[0]).onClick(view);
                        if (((Boolean) this.val$runs[1]).booleanValue()) {
                            if (!NewMoveCB.f37QH) {
                                NewMoveCB.f37QH = true;
                                this.val$_nmcbll2.setBackgroundDrawable(ASUI.roundBG(new String[]{"#DAFFCE", "#BBFFEA", "LR"}, new Integer(15), (String) null, (Object) null));
                            } else {
                                NewMoveCB.f37QH = false;
                                this.val$_nmcbll2.setBackgroundDrawable(ASUI.roundBG("#000000", new Integer(15), (String) null, (Object) null));
                            }
                        }
                    }
                    NewMoveCB.canmovew = false;
                } else if (action == 2) {
                    this.nowX = motionEvent.getRawX();
                    this.nowY = motionEvent.getRawY();
                    this.tranX = (float) Math.round(this.nowX - this.lastX);
                    this.tranY = (float) Math.round(this.nowY - this.lastY);
                    NewMoveCB newMoveCB = this.this$0;
                    newMoveCB.f38X = (int) (((float) newMoveCB.f38X) + this.tranX);
                    NewMoveCB newMoveCB2 = this.this$0;
                    newMoveCB2.f39Y = (int) (((float) newMoveCB2.f39Y) + this.tranY);
                    this.val$NewMoveCBcdv.update(Math.round((float) this.this$0.f38X), Math.round((float) this.this$0.f39Y), -1, -1);
                    this.lastX = this.nowX;
                    this.lastY = this.nowY;
                }
                return false;
            }
        });
        ASUI.UIFadein(newView, 0, 100, 500);
        return newCDV;
    }
}
